using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BKMPlayerControl : MonoBehaviour
{
    private Animator ani;
    private Rigidbody2D rbody;
    private bool isRun = false;

    void Start()
    {
        ani = GetComponent<Animator>();
        rbody = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical = Input.GetAxis("Vertical");

        isRun = false;
        if(horizontal!=0)
        {
            ani.SetFloat("Horizontal", horizontal);
            ani.SetFloat("Vertical", 0);
            isRun = true;
        }

        if (vertical != 0)
        {
            ani.SetFloat("Vertical", vertical);
            ani.SetFloat("Horizontal",0);
            isRun = true;
        }

        ani.SetBool("IsRun",isRun);

        Vector2 dir = new Vector2(horizontal,vertical);
        rbody.velocity = dir;

        //Debug.Log(horizontal);
    }
}
